/* client1.c
 *	Simple program to test the network
 *      This is the client 1
 */

#include "syscall.h"


void Print(char* str){
  int c = 0;
  while((str[c] != '\n')){
    c++; 
  }
  c++;
  Write(str,c,ConsoleOutput);
	
}

int main() {
  /*Variable declaration*/
  int lock0, lock1;
  int cond0, cond1;
  int loop;
  int choice;

 

  /***********************/
  /*Start test case 3 ****/
  Print("***** Start Test 3 ********\n");
  Print("Client : CREATE LOCK 0\n");

  lock0 = CreateLock(0); 

  Print("Client2: CREATE CONDITION 0\n");
  cond0 = CreateCondition(0);

  Print("Client2: ACQUIRE LOCK0\n");
  Acquire(lock0);

  Print("Client2: Lock 0 @ index: \n");
  PrintInt(lock0);
  Print(" \n");
  Print("Client2: Cond 0 @ index: \n");
  PrintInt(cond0);
  Print(" \n");
    

  Print("Client 2: WAIT LOCK 0 CONDITION 0\n");
  Wait(lock0,cond0);
  Print("Client 2: Waiting on lock 0 condition 0\n");

  for(loop = 0;loop <1234;loop++){
  }

  /***********************/
  /*Start test case 4 ****/
  Print("***** Start Test 4 ********\n");
  
  cond1 = CreateCondition(1);
 
  Print("Client2: ACQUIRE LOCK 1\n");
  Acquire(lock1);

  Print("Client 2: WAIT LOCK 1 CONDITION 1\n");
  Wait(lock1,cond1);
  Print("Client 2: Waiting on lock 1 condition 1\n");

 
  Print ("Done test case 3");
 
  Exit(0);
}
